package configuration;

import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Arrays;

/**
 * Created by wzl on 19-12-19.
 */
public class ModelerServerConfig {
    private String base_url;
    private String upload_point_path;
    private String get_point_path;
    private String namespace;
    private String entity_type;
    private String[] points;


    public String getBase_url() {
        return base_url;
    }

    public void setBase_url(String base_url) {
        this.base_url = base_url;
    }

    public String getUpload_point_path() {
        return upload_point_path;
    }

    public void setUpload_point_path(String upload_point_path) {
        this.upload_point_path = upload_point_path;
    }

    public String getGet_point_path() {
        return get_point_path;
    }

    public void setGet_point_path(String get_point_path) {
        this.get_point_path = get_point_path;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

    public String getEntity_type() {
        return entity_type;
    }

    public void setEntity_type(String entity_type) {
        this.entity_type = entity_type;
    }

    public String[] getPoints() {
        return points;
    }

    public void setPoints(String[] points) {
        this.points = points;
    }



    public static ModelerServerConfig initFromFile(String filepath) throws FileNotFoundException {
        Yaml yaml = new Yaml();
        ModelerServerConfig config = yaml.loadAs(new FileInputStream(new File(filepath)),
                ModelerServerConfig.class);
        return config;
    }

    @Override
    public String toString() {
        return "ModelerServerConfig {" +
                "\nbase_url = " + base_url +
                "\nupload_point_path = " + upload_point_path +
                "\nget_point_path = " + get_point_path +
                "\nnamespace = " + namespace +
                "\nentity_type = " + entity_type +
                "\npoints = " + Arrays.asList(points) +
                "\n}";
    }
}
